import Vue from 'vue'
import VueRouter from 'vue-router'
import Home from '../views/Home.vue'
import Leagues from "../views/Leagues";
import TeamStatistics from "../views/TeamStatistics";
import PlayerStatistics from "../views/PlayerStatistics";
import StatisticTotal  from '../views/StatisticTotal';
import SinglePlayer from "../components/singlePlayer/SinglePlayer";
import SingleTeam from "../components/singleTeam/SingleTeam";
import Uwb from "../views/Uwb";
import MatchReport from "../components/matchReport/MatchReport";
import MatchInfo from "../components/matchReport/reportComps/matchInfo/MatchInfo";
import MatchSquad from "../components/matchReport/reportComps/matchSquad/MatchSquad";
import PerformanceBattle from "../components/matchReport/reportComps/performanceBattle/PerformanceBattle";


//多次点击同一路由报错
const originalPush = VueRouter.prototype.push;

VueRouter.prototype.push = function push(location) {
  return originalPush.call(this, location).catch(err => err)
};


Vue.use(VueRouter);

const routes = [
  {
    path: '/',
    name: 'home',
    component: Home,
    children:[
      {
        path: '/league/:leagueId',
        name: 'league',
        component: Leagues
      },
      {
        path: '/team/statistics',
        name: 'teamStatistics',
        component: TeamStatistics
      },
      {
        path: '/player/statistics',
        name: 'playerStatistics',
        component: PlayerStatistics,
      },
      {
        path: '/total/statistics',
        name: 'statisticTotal',
        component: StatisticTotal,
      },
      {
        path: '/player/:playerId',
        name: 'singlePlayer',
        component: SinglePlayer
      },
      {
        path: '/team/:teamId',
        name: 'singleTeam',
        component: SingleTeam
      },
      {
        path: '/matchReport/:matchId',
        name: 'matchReport',
        redirect: '/matchReport/:matchId/matchInfo',
        component: MatchReport,
        children:[
          {
            path: 'matchInfo',
            name: 'matchInfo',
            component: MatchInfo,
          },
          {
            path: 'matchSquad',
            name: 'matchSquad',
            component: MatchSquad,
          },
          {
            path: 'performanceBattle',
            name: 'performanceBattle',
            component: PerformanceBattle,
          },
        ]
      },
      {
        path: 'uwb',
        name: 'uwb',
        component: Uwb
      },
    ],
  },
];

const router = new VueRouter({
  routes
});

export default router
